class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :set_locale
  helper_method :current_user
  
  rescue_from CanCan::AccessDenied do |exception|
    gflash :error => { :value => "No tiene priviegios para ingrear, intente inicindo sesion",:title => "Acceso denegado",:sticky=>true}           
    redirect_to :root, :params => @params
  end

  def set_locale
      I18n.locale = params[:locale] if params[:locale]
    end
  
  private
  def current_user
    @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
  end
  
  
end
